﻿'******************************************************************************
'Description:删除批次接口实现类
'Copyright (c) : 通力凯顿（北京）系统集成有限公司
'Writer:Zhangll
'create Date:2016.05.19
'Rewriter:
'Rewrite Date:Date:
'********************************************************************************
Imports System.Text
'******************************************************************************
'Description:删除批次接口实现类
'Copyright (c) : 通力凯顿（北京）系统集成有限公司
'Writer:Zhangll
'create Date:2016.05.19
'Rewriter:
'Rewrite Date:Date:
'********************************************************************************

Imports BusinessRule.IBusiness
Imports DatabaseAccess.IDAL
Imports System.Data
Imports BusinessRule.DTO
Imports BusinessRule.Common
Imports DatabaseAccess.DALFactory
Imports External.APICalling
Imports Camstar.WebClient.WebServicesProxy.InSiteWebServices
Public Class uMESContainerDelBusiness
    Implements BusinessRule.IBusiness.uMESContainerDelIBusiness
    Private dal As IOracleDAL = uMESDalContext.instance.GetDalObject()

    Public Function UpdateContainer(ByVal container As String) As Boolean Implements IBusiness.uMESContainerDelIBusiness.UpdateContainer
        UpdateContainer = False
        Dim sb As New StringBuilder
        sb.AppendFormat(" update container c set c.containername=c.containerid,c.status=0 where c.containername in ({0})", container)
        UpdateContainer = dal.ExecuteSql(sb.ToString)
    End Function
    Public Function GetContainerInfo(ByVal para As Dictionary(Of String, String)) As uMESProcessResult Implements IBusiness.uMESContainerDelIBusiness.GetContainerInfo
        Dim sb As New StringBuilder
        sb.AppendLine(" select c.containername,pb.productname,c.qty,e.fullname,c.originalstartdate from container c")
        sb.AppendLine(" left join product p on p.productid=c.productid")
        sb.AppendLine(" left join productbase pb on pb.productbaseid=p.productbaseid")
        sb.AppendLine(" left join employee e on e.employeeid=c.startemployeeid")
        sb.AppendLine(" where c.containerid<>c.containername and c.parentcontainerid is null and c.splitfromid is null ")
        If para.Keys.Contains("productname") = True Then
            sb.AppendLine(" AND  LOWER(pb.productname) LIKE '%" & para("productname").ToString.ToLower & "%' ")
        End If
        If para.Keys.Contains("containername") = True Then
            sb.AppendLine(" AND  LOWER(c.containername) LIKE '%" & para("containername").ToString.ToLower & "%' ")
        End If
        Dim paraPage As New uMESPagingDataDTO
        paraPage.CurrentPageIndex = Convert.ToInt32(para("CurrentPageIndex").ToString)
        paraPage.PageSize = Convert.ToInt32(para("PageSize").ToString)
        paraPage.strSQL = sb.ToString
        Dim r As uMESProcessResult = dal.RunProcedureForPage(paraPage)
        Return r
    End Function
End Class
